home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performProjectCurve.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  9.2 KB  |  345 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  April 24, 1997
  22. //  Author:         ramesh 
  23. //
  24. //  Description:
  25. //      This script is defines the option box for the projectCurve menu item.
  26. //
  27. //  Input Arguments:
  28. //      int action
  29. //          0 - show the option box dialog
  30. //        1 - just execute the projectCurve operation
  31. //
  32. //  Return Value:
  33. //      None.
  34. //
  35.  
  36.  
  37. proc setOptionVars (int $forceFactorySettings)
  38. {
  39.     projectCurveSetOptionVars( $forceFactorySettings );
  40. }
  41.  
  42. global proc projectCurveSetup( string $parent,
  43.                                int $forceFactorySettings,
  44.                                string $goToTool )
  45. {
  46.     // retrieve option settings.
  47.     //
  48.     setOptionVars($forceFactorySettings);    
  49.     projectToolSetup( $forceFactorySettings, $goToTool );
  50.  
  51.     setParent $parent;    
  52.  
  53.     // query all the option vars.
  54.     //
  55.     int $curveRangePartial = `optionVar -q projectCurveRangePartial`+1 ;
  56.     radioButtonGrp -edit -select $curveRangePartial curveRangeRadioButtonGrp ;        
  57.     int $dir = `optionVar -q projectCurveAlongDirection`+1 ;
  58.     radioButtonGrp -edit -select $dir projectVectorTypeRadioButton ;
  59.         
  60.     // Global vs. local tolerance
  61.     int $useGlobalTol = `optionVar -q projectCurveUseGlobalTol`;
  62.     radioButtonGrp -e -select (2 - $useGlobalTol) useGlobalTolBtn;
  63.  
  64.     //    Tolerance
  65.     //
  66.     floatSliderGrp -edit 
  67.         -v `optionVar -q projectCurveTolerance`
  68.         projectCurveTolSlider;
  69.  
  70.     if( $useGlobalTol ) {
  71.         tabLayout -e -selectTab noSlider useGlobalTolTab;
  72.     }
  73.     else {
  74.         tabLayout -e -selectTab slider useGlobalTolTab;
  75.     }
  76.  
  77.     if( "" != $goToTool ) { 
  78.         checkBoxGrp -e -v1 `scriptCtx -q -euc $goToTool`
  79.           scriptToolExtraWidget;
  80.         checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool`
  81.           scriptToolExtraWidget;
  82.     }
  83. }
  84.  
  85.  
  86. global proc projectCurveCallback( string $parent, int $doIt, string $goToTool )
  87. {
  88.     if( "" != $goToTool ) {
  89.         optionVar -iv projectCurveEuc `scriptCtx -q -euc $goToTool`;
  90.         optionVar -iv projectCurveLac `scriptCtx -q -lac $goToTool`;
  91.     }
  92.     setParent $parent ;
  93.  
  94.     // get Values from controls.
  95.     //
  96.     int $curveRangePartial =
  97.         `radioButtonGrp -q -select curveRangeRadioButtonGrp` - 1 ;
  98.     optionVar -intValue projectCurveRangePartial $curveRangePartial ;
  99.  
  100.     // project curve direction.
  101.     //
  102.     int $dir = `radioButtonGrp -q -select projectVectorTypeRadioButton` - 1 ;
  103.     optionVar -intValue projectCurveAlongDirection $dir  ;
  104.  
  105.     // global vs. local tolerance
  106.     int $useGlobalTol = 2 - `radioButtonGrp -q -select useGlobalTolBtn`;
  107.     optionVar -intValue projectCurveUseGlobalTol $useGlobalTol;
  108.  
  109.     // tolerance
  110.     optionVar -floatValue projectCurveTolerance
  111.         `floatSliderGrp -q -v projectCurveTolSlider`;
  112.  
  113.     if( 1 == $doIt ) {
  114.         performProjectCurve( 0, $goToTool ) ; 
  115.         string $tmpCmd = "performProjectCurve( 0, \"" + $goToTool + "\")";
  116.         addToRecentCommandQueue $tmpCmd "Project Curve On Surface";
  117.     }
  118.     else if( $doIt ) {
  119.         setToolTo $goToTool;
  120.     }
  121. }
  122.  
  123. proc projectCurveOptions( int $inTheTool, string $goToTool )
  124. {
  125.     //    Name of the command for this option box.
  126.     //
  127.     string $commandName = "projectCurve";
  128.  
  129.     //    Build the option box actions.
  130.     //
  131.     string $callback = ($commandName + "Callback");
  132.     string $setup = ($commandName + "Setup");
  133.  
  134.     global string $gOptionBoxActionToolItem;
  135.     $gOptionBoxActionToolItem = "modelWithToolProject";
  136.     global string $gOptionBoxActionToolItemCB;
  137.     $gOptionBoxActionToolItemCB = "projectToolScript 3";
  138.  
  139.     //    Step 1:  Get the option box.
  140.     //    ============================
  141.     string $layout = getOptionBox();
  142.     setParent $layout;
  143.     
  144.     //    Step 2:  Pass the command name to the option box.
  145.     //    =================================================
  146.     setOptionBoxCommandName($commandName);
  147.     
  148.     //    Step 3:  Activate the default UI template.
  149.     //    ==========================================
  150.     setUITemplate -pushTemplate DefaultTemplate;
  151.  
  152.     //    Step 4: Create option box contents.
  153.     //    ===================================
  154.     
  155.     //    Turn on the wait cursor.
  156.     //
  157.     waitCursor -state 1;
  158.  
  159.     tabLayout -scr true -tv false;
  160.     
  161.     string $parent = `columnLayout -adjustableColumn 1`;
  162.     
  163.     radioButtonGrp -nrb 2 -select 1 -l "Project Along" -l1 "Active View" -da1 0
  164.         -l2 "Surface Normal" -da2 1 projectVectorTypeRadioButton;
  165.  
  166.     radioButtonGrp -nrb 2 -l "Use Tolerance"
  167.        -l1 "Global"
  168.        -l2 "Local"
  169.        -on1 "tabLayout -e -selectTab noSlider useGlobalTolTab"
  170.        -on2 "tabLayout -e -selectTab slider useGlobalTolTab"
  171.        useGlobalTolBtn;
  172.  
  173.     tabLayout -tabsVisible false useGlobalTolTab;
  174.        columnLayout slider;
  175.            floatSliderGrp -l "Tolerance" 
  176.                -min 0.001 -max 1.0 -fmn 0.00001 -fmx 10.0
  177.                projectCurveTolSlider;
  178.        setParent ..;
  179.        columnLayout noSlider;
  180.        setParent ..;
  181.     setParent ..;
  182.  
  183.    separator;
  184.  
  185.     radioButtonGrp -numberOfRadioButtons 2 
  186.         -label "Curve Range" -label1 "Complete" -da1 0
  187.         -label2 "Partial" -da2 1 -select 1 curveRangeRadioButtonGrp;
  188.  
  189.     if( $inTheTool ) {
  190.         separator;
  191.         checkBoxGrp -ncb 2 -l "Tool Behavior"
  192.           -l1 "Exit on Completion"
  193.           -v1 off
  194.           -on1 ("scriptCtx -e -euc true " + $goToTool)
  195.           -of1 ("scriptCtx -e -euc false " + $goToTool)
  196.  
  197.           -l2 "Auto Completion"
  198.           -v2 on
  199.           -on2 ("scriptCtx -e -lac true " + $goToTool)
  200.           -of2 ("scriptCtx -e -lac false " + $goToTool)
  201.           scriptToolExtraWidget;
  202.     }
  203.     //    Turn off the wait cursor.
  204.     //
  205.     waitCursor -state 0;
  206.     
  207.     //    Step 5: Deactivate the default UI template.
  208.     //  ===========================================
  209.     //
  210.     setUITemplate -popTemplate;
  211.  
  212.     //    Step 6: Customize the buttons.  
  213.     //    ==============================
  214.  
  215.     //    'Apply' button.
  216.     //
  217.     string $applyBtn = getOptionBoxApplyBtn();
  218.     if( $inTheTool ) {
  219.         button -edit -l "Project Tool"
  220.             -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"")
  221.             $applyBtn;
  222.     }
  223.     else {
  224.         button -edit -l "Project"
  225.             -command ($callback + " " + $parent + " 1 \"" + $goToTool + "\"")
  226.             $applyBtn;
  227.     }
  228.  
  229.     //    'Save' button.
  230.     //
  231.     string $saveBtn = getOptionBoxSaveBtn();
  232.     button -edit 
  233.         -command ($callback + " " + $parent + " 0 \"" +
  234.                   $goToTool + "\"; hideOptionBox")
  235.         $saveBtn;
  236.  
  237.     //    'Reset' button.
  238.     //
  239.     string $resetBtn = getOptionBoxResetBtn();
  240.     button -edit 
  241.         -command ($setup + " " + $parent + " 1 \"" + $goToTool + "\"")
  242.         $resetBtn;
  243.  
  244.     //    Step 7: Set the option box title.
  245.     //    =================================
  246.     //
  247.     if( $inTheTool ) {
  248.         setOptionBoxTitle("Project Curve on Surface Tool Options");
  249.     }
  250.     else {
  251.         setOptionBoxTitle("Project Curve on Surface Options");
  252.     }
  253.  
  254.     //    Step 8: Customize the 'Help' menu item text.
  255.     //    ============================================
  256.     //
  257.     setOptionBoxHelpTag( "ProjectCurveOnSurface" );
  258.  
  259.     //    Step 9: Set the current values of the option box.
  260.     //    =================================================
  261.     //
  262.     eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\"");    
  263.     
  264.     //    Step 10: Show the option box.
  265.     //    =============================
  266.     //
  267.     showOptionBox();
  268. }
  269.  
  270. proc string projectCurveHelp()
  271. {
  272.     string $help = "  Command: Project Curve - project a curve onto a surface\n"
  273.         + "Selection: curves to project and surfaces onto which to project.";
  274.     return $help ;
  275. }
  276.  
  277. proc string assembleCmd()
  278. //
  279. //    Description :
  280. //        To assemble projectCurve proc.
  281. //
  282. {
  283.     setOptionVars(false);
  284.  
  285.     string $cmd = "projectCurvePreset"  ;
  286.     $cmd = $cmd + "(" ;  
  287.  
  288.     int $history = `constructionHistory -q -tgl`;
  289.     $cmd = $cmd + $history ;  
  290.     $cmd = $cmd + "," ;  
  291.  
  292.     int $curveRangePartial = `optionVar -q projectCurveRangePartial` ;
  293.     $cmd = $cmd + $curveRangePartial ;  
  294.     $cmd = $cmd + "," ;  
  295.  
  296.     int $viewDir = `optionVar -q projectCurveAlongDirection` ;
  297.     $cmd = $cmd + $viewDir ;
  298.     $cmd = $cmd + "," ;  
  299.   
  300.     float $tol = `optionVar -q projectCurveTolerance`;
  301.     if( `optionVar -q projectCurveUseGlobalTol` ) {
  302.         $tol = `optionVar -q positionalTolerance`;
  303.     }
  304.     $cmd = $cmd + $tol ;
  305.   
  306.     $cmd = $cmd + ")" ;  
  307.     return $cmd ;
  308.  
  309. }
  310.  
  311. global proc string performProjectCurve( int $action, string $goToTool )
  312. //
  313. //    Description :
  314. //      0 - Execute the command.
  315. //      1 - Show the option box dialog.
  316. //      2 - Return the command.
  317. //      3 - Show the tool option box dialog.
  318. {
  319.     int $inTheTool = false;
  320.     if( 3 == $action ) {
  321.         $action = 1;
  322.         $inTheTool = true;
  323.     }
  324.  
  325.     string $cmd = "" ;
  326.     switch( $action ) {
  327.  
  328.       case 0 :
  329.         $cmd = `assembleCmd`;
  330.         eval $cmd ;
  331.         break ;
  332.  
  333.       case 1 :
  334.         projectCurveOptions( $inTheTool, $goToTool );
  335.         break ;
  336.  
  337.       case 2 :
  338.       default:
  339.         $cmd = `assembleCmd` ;
  340.         break ;
  341.     }
  342.     return $cmd ;
  343. }
  344.  
  345.